<?php


namespace app\index\service;
use think\Image;

class ImageService
{
    /*统一上传函数*/
    public function upload($url)
    {
        $file = request()->file('uploadfile_ant');
        $info = $file->move($url);
        if ($info) {
            $yphotograph = $info->getSaveName();//压缩图片
            $getSaveName = str_replace('\\', '/', $yphotograph);
            $image = Image::open($info);
            $image->thumb(700, 1000)->save($url . $getSaveName);
            $img = $url . $getSaveName;
            return $img;
        }else{
            echo $file->getError();
            die();
        }
    }
}